package com.skynet.whwpro.module;


        import com.skynet.whwpro.bean.BeanDyb;
        import com.skynet.whwpro.bean.BeanJyjlb;
        import com.skynet.whwpro.bean.BeanSjzcb;
        import org.nutz.dao.Cnd;
        import org.nutz.dao.Dao;
        import org.nutz.dao.QueryResult;
        import org.nutz.dao.pager.Pager;
        import org.nutz.ioc.loader.annotation.Inject;
        import org.nutz.ioc.loader.annotation.IocBean;
        import org.nutz.lang.Strings;
        import org.nutz.lang.util.NutMap;
        import org.nutz.mvc.adaptor.JsonAdaptor;
        import org.nutz.mvc.annotation.*;

        import java.util.List;

        @At("/yhbzxcx_sjzcb")
        @IocBean
        public class SjzcbModule {

        @Inject
        private Dao dao;

        @Ok("raw")
        @At
        public long count() {
        return dao.count(BeanSjzcb.class);
        }

        @At
        public NutMap query(@Param("userid") String userid) {
        List<BeanSjzcb> users = dao.query(BeanSjzcb.class, Cnd.where("wyid","=",userid).orderBy().desc("wyid"));
        return new NutMap("ok", true).setv("data", users);
        }

        @At
        @POST
        public NutMap add(@Param("..") BeanSjzcb Sjzcb) {
        if (Strings.isBlank(Sjzcb.getWyid()))
        return new NutMap("ok", false);
        dao.insert(Sjzcb);
        return new NutMap("ok", true);
        }

        @At
        @POST
        public NutMap delete(long id) {
        dao.clear(BeanSjzcb.class, Cnd.where("xsdid", "=", id));
        return new NutMap("ok", true);
        }

        @At
        @POST
        @AdaptBy(type= JsonAdaptor.class)
        public NutMap update(@Param("..") BeanSjzcb user) {
        dao.update(user);
        return new NutMap("ok", true);
        }
        }
